import json
import os
import xlwt

workbook = xlwt.Workbook()

path = 'outcome'

listModel = os.listdir(path)

for model_DL in listModel:
    cnt = 1
    sheet = workbook.add_sheet(model_DL)
    for directory in os.listdir(path + '/' + model_DL):
        for subSet in os.listdir(path + '/' + model_DL + '/' + directory):
            with open(path + '/' + model_DL + '/' + directory + '/' + subSet, 'r') as load_file:
                outcome = json.load(load_file)
                subDataSet = outcome['subDataSet']
                result = outcome['result']

                sheet.write(1, cnt, outcome["subDataSet"])
                # sheet.write(2, cnt, result[0]['train samples'])
                # sheet.write(3, cnt, result[0]['defective train samples'])
                sheet.write(4, cnt, result[0]['precision'])
                sheet.write(5, cnt, result[0]['recall'])
                sheet.write(6, cnt, result[0]['pf'])
                sheet.write(7, cnt, result[0]['F-measure'])
                sheet.write(8, cnt, result[0]['accuracy'])
                sheet.write(9, cnt, result[0]['AUC'])
                cnt += 1

workbook.save('supervised' + '.xlsx')
